// 2025/5/26
// ruby和薯条

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long dispre(vector<int>& a, int dis)
{
    long long ans = 0;
    int n = a.size(), left = 0, right = 1;
    while(right < n)
    {
        int cur = a[right] - a[left];
        while(cur > dis)
        {
            cur = a[right] - a[++left];
        }
        ans += right - left + 1;
        right++;
    }
    return ans;
}

int main() {
    int n, l, r; 
    cin >> n >> l >> r;
    vector<int> a(n);
    for(auto& ai : a) cin >> ai;
    sort(a.begin(), a.end());

    long long ans = dispre(a, r) - dispre(a, l - 1);
    cout << ans << endl;
}
// 64 位输出请用 printf("%lld")